<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>GAsyncInitable</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="GIO 参考手册">
<link rel="up" href="failable_initialization.html" title="Failable Initialization">
<link rel="prev" href="gio-GInitable.html" title="GInitable">
<link rel="next" href="networking.html" title="Lowlevel network support">
<meta name="generator" content="GTK-Doc V1.17 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="gio-GInitable.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="failable_initialization.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GIO 参考手册</th>
<td><a accesskey="n" href="networking.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#gio-GAsyncInitable.synopsis" class="shortcut">Top</a>
                   | 
                  <a href="#gio-GAsyncInitable.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry">
<a name="gio-GAsyncInitable"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="gio-GAsyncInitable.top_of_page"></a>GAsyncInitable</span></h2>
<p>GAsyncInitable — Asynchronously failable object initialization interface</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<a name="gio-GAsyncInitable.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">
#include &lt;gio/gio.h&gt;

                    <a class="link" href="gio-GAsyncInitable.html#GAsyncInitable" title="GAsyncInitable">GAsyncInitable</a>;
struct              <a class="link" href="gio-GAsyncInitable.html#GAsyncInitableIface" title="struct GAsyncInitableIface">GAsyncInitableIface</a>;
<span class="returnvalue">void</span>                <a class="link" href="gio-GAsyncInitable.html#g-async-initable-init-async" title="g_async_initable_init_async ()">g_async_initable_init_async</a>         (<em class="parameter"><code><a class="link" href="gio-GAsyncInitable.html#GAsyncInitable" title="GAsyncInitable"><span class="type">GAsyncInitable</span></a> *initable</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> io_priority</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gio-GCancellable.html#GCancellable" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gio-GAsyncResult.html#GAsyncReadyCallback" title="GAsyncReadyCallback ()"><span class="type">GAsyncReadyCallback</span></a> callback</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> user_data</code></em>);
<a href="../glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="gio-GAsyncInitable.html#g-async-initable-init-finish" title="g_async_initable_init_finish ()">g_async_initable_init_finish</a>        (<em class="parameter"><code><a class="link" href="gio-GAsyncInitable.html#GAsyncInitable" title="GAsyncInitable"><span class="type">GAsyncInitable</span></a> *initable</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gio-GAsyncResult.html#GAsyncResult" title="GAsyncResult"><span class="type">GAsyncResult</span></a> *res</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="gio-GAsyncInitable.html#g-async-initable-new-async" title="g_async_initable_new_async ()">g_async_initable_new_async</a>          (<em class="parameter"><code><a href="../gobject/gobject-Type-Information.html#GType"><span class="type">GType</span></a> object_type</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> io_priority</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gio-GCancellable.html#GCancellable" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gio-GAsyncResult.html#GAsyncReadyCallback" title="GAsyncReadyCallback ()"><span class="type">GAsyncReadyCallback</span></a> callback</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> user_data</code></em>,
                                                         <em class="parameter"><code>const <a href="../glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *first_property_name</code></em>,
                                                         <em class="parameter"><code>...</code></em>);
<a href="../gobject/gobject-The-Base-Object-Type.html#GObject"><span class="returnvalue">GObject</span></a> *           <a class="link" href="gio-GAsyncInitable.html#g-async-initable-new-finish" title="g_async_initable_new_finish ()">g_async_initable_new_finish</a>         (<em class="parameter"><code><a class="link" href="gio-GAsyncInitable.html#GAsyncInitable" title="GAsyncInitable"><span class="type">GAsyncInitable</span></a> *initable</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gio-GAsyncResult.html#GAsyncResult" title="GAsyncResult"><span class="type">GAsyncResult</span></a> *res</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="gio-GAsyncInitable.html#g-async-initable-new-valist-async" title="g_async_initable_new_valist_async ()">g_async_initable_new_valist_async</a>   (<em class="parameter"><code><a href="../gobject/gobject-Type-Information.html#GType"><span class="type">GType</span></a> object_type</code></em>,
                                                         <em class="parameter"><code>const <a href="../glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *first_property_name</code></em>,
                                                         <em class="parameter"><code><span class="type">va_list</span> var_args</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> io_priority</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gio-GCancellable.html#GCancellable" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gio-GAsyncResult.html#GAsyncReadyCallback" title="GAsyncReadyCallback ()"><span class="type">GAsyncReadyCallback</span></a> callback</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> user_data</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="gio-GAsyncInitable.html#g-async-initable-newv-async" title="g_async_initable_newv_async ()">g_async_initable_newv_async</a>         (<em class="parameter"><code><a href="../gobject/gobject-Type-Information.html#GType"><span class="type">GType</span></a> object_type</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#guint"><span class="type">guint</span></a> n_parameters</code></em>,
                                                         <em class="parameter"><code><a href="../gobject/gobject-The-Base-Object-Type.html#GParameter"><span class="type">GParameter</span></a> *parameters</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> io_priority</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gio-GCancellable.html#GCancellable" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gio-GAsyncResult.html#GAsyncReadyCallback" title="GAsyncReadyCallback ()"><span class="type">GAsyncReadyCallback</span></a> callback</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> user_data</code></em>);
</pre>
</div>
<div class="refsect1">
<a name="gio-GAsyncInitable.description"></a><h2>Description</h2>
<p>
This is the asynchronous version of <a class="link" href="gio-GInitable.html#GInitable" title="GInitable"><span class="type">GInitable</span></a>; it behaves the same
in all ways except that initialization is asynchronous. For more details
see the descriptions on <a class="link" href="gio-GInitable.html#GInitable" title="GInitable"><span class="type">GInitable</span></a>.
</p>
<p>
A class may implement both the <a class="link" href="gio-GInitable.html#GInitable" title="GInitable"><span class="type">GInitable</span></a> and <a class="link" href="gio-GAsyncInitable.html#GAsyncInitable" title="GAsyncInitable"><span class="type">GAsyncInitable</span></a> interfaces.
</p>
<p>
Users of objects implementing this are not intended to use the interface
method directly; instead it will be used automatically in various ways.
For C applications you generally just call <a class="link" href="gio-GAsyncInitable.html#g-async-initable-new-async" title="g_async_initable_new_async ()"><code class="function">g_async_initable_new_async()</code></a>
directly, or indirectly via a <code class="function">foo_thing_new_async()</code> wrapper. This will call
<a class="link" href="gio-GAsyncInitable.html#g-async-initable-init-async" title="g_async_initable_init_async ()"><code class="function">g_async_initable_init_async()</code></a> under the cover, calling back with <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> and
a set <a href="../glib/glib-Error-Reporting.html#GError"><code class="literal">GError</code></a> on failure.
</p>
<p>
A typical implementation might look something like this:
</p>
<p>
</p>
<div class="informalexample"><pre class="programlisting">
enum {
   NOT_INITIALIZED,
   INITIALIZING,
   INITIALIZED
};

static void
_foo_ready_cb (Foo *self)
{
  GList *l;

  self-&gt;priv-&gt;state = INITIALIZED;

  for (l = self-&gt;priv-&gt;init_results; l != NULL; l = l-&gt;next)
    {
      GSimpleAsyncResult *simple = l-&gt;data;

      if (!self-&gt;priv-&gt;success)
        g_simple_async_result_set_error (simple, ...);

      g_simple_async_result_complete (simple);
      g_object_unref (simple);
    }

  g_list_free (self-&gt;priv-&gt;init_results);
  self-&gt;priv-&gt;init_results = NULL;
}

static void
foo_init_async (GAsyncInitable       *initable,
                int                   io_priority,
                GCancellable         *cancellable,
                GAsyncReadyCallback   callback,
                gpointer              user_data)
{
  Foo *self = FOO (initable);
  GSimpleAsyncResult *simple;

  simple = g_simple_async_result_new (G_OBJECT (initable)
                                      callback,
                                      user_data,
                                      foo_init_async);

  switch (self-&gt;priv-&gt;state)
    {
      case NOT_INITIALIZED:
        _foo_get_ready (self);
        self-&gt;priv-&gt;init_results = g_list_append (self-&gt;priv-&gt;init_results,
                                                  simple);
        self-&gt;priv-&gt;state = INITIALIZING;
        break;
      case INITIALIZING:
        self-&gt;priv-&gt;init_results = g_list_append (self-&gt;priv-&gt;init_results,
                                                  simple);
        break;
      case INITIALIZED:
        if (!self-&gt;priv-&gt;success)
          g_simple_async_result_set_error (simple, ...);

        g_simple_async_result_complete_in_idle (simple);
        g_object_unref (simple);
        break;
    }
}

static gboolean
foo_init_finish (GAsyncInitable       *initable,
                 GAsyncResult         *result,
                 GError              **error)
{
  g_return_val_if_fail (g_simple_async_result_is_valid (result,
      G_OBJECT (initable), foo_init_async), FALSE);

  if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result),
          error))
    return FALSE;

  return TRUE;
}

static void
foo_async_initable_iface_init (gpointer g_iface,
                               gpointer data)
{
  GAsyncInitableIface *iface = g_iface;

  iface-&gt;init_async = foo_init_async;
  iface-&gt;init_finish = foo_init_finish;
}
</pre></div>
<p>
</p>
</div>
<div class="refsect1">
<a name="gio-GAsyncInitable.details"></a><h2>Details</h2>
<div class="refsect2">
<a name="GAsyncInitable"></a><h3>GAsyncInitable</h3>
<pre class="programlisting">typedef struct _GAsyncInitable GAsyncInitable;</pre>
<p>
Interface for asynchronously initializable objects.
</p>
<p class="since">Since 2.22</p>
</div>
<hr>
<div class="refsect2">
<a name="GAsyncInitableIface"></a><h3>struct GAsyncInitableIface</h3>
<pre class="programlisting">struct GAsyncInitableIface {
  GTypeInterface g_iface;

  /* Virtual Table */

  void     (* init_async)  (GAsyncInitable      *initable,
			    int                  io_priority,
			    GCancellable        *cancellable,
			    GAsyncReadyCallback  callback,
			    gpointer             user_data);
  gboolean (* init_finish) (GAsyncInitable      *initable,
			    GAsyncResult        *res,
			    GError             **error);
};
</pre>
<p>
Provides an interface for asynchronous initializing object such that
initialization may fail.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><a href="../gobject/gobject-Type-Information.html#GTypeInterface"><span class="type">GTypeInterface</span></a> <em class="structfield"><code><a name="GAsyncInitableIface.g-iface"></a>g_iface</code></em>;</span></p></td>
<td>The parent interface.</td>
</tr>
<tr>
<td><p><span class="term"><em class="structfield"><code><a name="GAsyncInitableIface.init-async"></a>init_async</code></em> ()</span></p></td>
<td>Starts initialization of the object.</td>
</tr>
<tr>
<td><p><span class="term"><em class="structfield"><code><a name="GAsyncInitableIface.init-finish"></a>init_finish</code></em> ()</span></p></td>
<td>Finishes initialization of the object.</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.22</p>
</div>
<hr>
<div class="refsect2">
<a name="g-async-initable-init-async"></a><h3>g_async_initable_init_async ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_async_initable_init_async         (<em class="parameter"><code><a class="link" href="gio-GAsyncInitable.html#GAsyncInitable" title="GAsyncInitable"><span class="type">GAsyncInitable</span></a> *initable</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> io_priority</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gio-GCancellable.html#GCancellable" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gio-GAsyncResult.html#GAsyncReadyCallback" title="GAsyncReadyCallback ()"><span class="type">GAsyncReadyCallback</span></a> callback</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
<p>
Starts asynchronous initialization of the object implementing the
interface. This must be done before any real use of the object after
initial construction. If the object also implements <a class="link" href="gio-GInitable.html#GInitable" title="GInitable"><span class="type">GInitable</span></a> you can
optionally call <a class="link" href="gio-GInitable.html#g-initable-init" title="g_initable_init ()"><code class="function">g_initable_init()</code></a> instead.
</p>
<p>
When the initialization is finished, <em class="parameter"><code>callback</code></em> will be called. You can
then call <a class="link" href="gio-GAsyncInitable.html#g-async-initable-init-finish" title="g_async_initable_init_finish ()"><code class="function">g_async_initable_init_finish()</code></a> to get the result of the
initialization.
</p>
<p>
Implementations may also support cancellation. If <em class="parameter"><code>cancellable</code></em> is not
<a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, then initialization can be cancelled by triggering the cancellable
object from another thread. If the operation was cancelled, the error
<a class="link" href="gio-GIOError.html#G-IO-ERROR-CANCELLED:CAPS"><code class="literal">G_IO_ERROR_CANCELLED</code></a> will be returned. If <em class="parameter"><code>cancellable</code></em> is not <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>, and
the object doesn't support cancellable initialization, the error
<a class="link" href="gio-GIOError.html#G-IO-ERROR-NOT-SUPPORTED:CAPS"><code class="literal">G_IO_ERROR_NOT_SUPPORTED</code></a> will be returned.
</p>
<p>
If this function is not called, or returns with an error, then all
operations on the object should fail, generally returning the
error <a class="link" href="gio-GIOError.html#G-IO-ERROR-NOT-INITIALIZED:CAPS"><code class="literal">G_IO_ERROR_NOT_INITIALIZED</code></a>.
</p>
<p>
Implementations of this method must be idempotent: i.e. multiple calls
to this function with the same argument should return the same results.
Only the first call initializes the object; further calls return the result
of the first call. This is so that it's safe to implement the singleton
pattern in the GObject constructor function.
</p>
<p>
For classes that also support the <a class="link" href="gio-GInitable.html#GInitable" title="GInitable"><span class="type">GInitable</span></a> interface, the default
implementation of this method will run the <a class="link" href="gio-GInitable.html#g-initable-init" title="g_initable_init ()"><code class="function">g_initable_init()</code></a> function
in a thread, so if you want to support asynchronous initialization via
threads, just implement the <a class="link" href="gio-GAsyncInitable.html#GAsyncInitable" title="GAsyncInitable"><span class="type">GAsyncInitable</span></a> interface without overriding
any interface methods.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>initable</code></em> :</span></p></td>
<td>a <a class="link" href="gio-GAsyncInitable.html#GAsyncInitable" title="GAsyncInitable"><span class="type">GAsyncInitable</span></a>.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>io_priority</code></em> :</span></p></td>
<td>the <a class="link" href="gio-GIOScheduler.html#io-priority">I/O priority</a>
of the operation.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>cancellable</code></em> :</span></p></td>
<td>optional <a class="link" href="gio-GCancellable.html#GCancellable" title="GCancellable"><span class="type">GCancellable</span></a> object, <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>callback</code></em> :</span></p></td>
<td>a <a class="link" href="gio-GAsyncResult.html#GAsyncReadyCallback" title="GAsyncReadyCallback ()"><span class="type">GAsyncReadyCallback</span></a> to call when the request is satisfied</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
<td>the data to pass to callback function</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.22</p>
</div>
<hr>
<div class="refsect2">
<a name="g-async-initable-init-finish"></a><h3>g_async_initable_init_finish ()</h3>
<pre class="programlisting"><a href="../glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>            g_async_initable_init_finish        (<em class="parameter"><code><a class="link" href="gio-GAsyncInitable.html#GAsyncInitable" title="GAsyncInitable"><span class="type">GAsyncInitable</span></a> *initable</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gio-GAsyncResult.html#GAsyncResult" title="GAsyncResult"><span class="type">GAsyncResult</span></a> *res</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre>
<p>
Finishes asynchronous initialization and returns the result.
See <a class="link" href="gio-GAsyncInitable.html#g-async-initable-init-async" title="g_async_initable_init_async ()"><code class="function">g_async_initable_init_async()</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>initable</code></em> :</span></p></td>
<td>a <a class="link" href="gio-GAsyncInitable.html#GAsyncInitable" title="GAsyncInitable"><span class="type">GAsyncInitable</span></a>.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>res</code></em> :</span></p></td>
<td>a <a class="link" href="gio-GAsyncResult.html#GAsyncResult" title="GAsyncResult"><span class="type">GAsyncResult</span></a>.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
<td>a <a href="../glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> location to store the error occuring, or <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to
ignore.</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<a href="../glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if successful. If an error has occurred, this function
will return <a href="../glib/glib-Standard-Macros.html#FALSE:CAPS"><code class="literal">FALSE</code></a> and set <em class="parameter"><code>error</code></em> appropriately if present.</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.22</p>
</div>
<hr>
<div class="refsect2">
<a name="g-async-initable-new-async"></a><h3>g_async_initable_new_async ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_async_initable_new_async          (<em class="parameter"><code><a href="../gobject/gobject-Type-Information.html#GType"><span class="type">GType</span></a> object_type</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> io_priority</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gio-GCancellable.html#GCancellable" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gio-GAsyncResult.html#GAsyncReadyCallback" title="GAsyncReadyCallback ()"><span class="type">GAsyncReadyCallback</span></a> callback</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> user_data</code></em>,
                                                         <em class="parameter"><code>const <a href="../glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *first_property_name</code></em>,
                                                         <em class="parameter"><code>...</code></em>);</pre>
<p>
Helper function for constructing <span class="type">GAsyncInitiable</span> object. This is
similar to <a href="../gobject/gobject-The-Base-Object-Type.html#g-object-new"><code class="function">g_object_new()</code></a> but also initializes the object asynchronously.
</p>
<p>
When the initialization is finished, <em class="parameter"><code>callback</code></em> will be called. You can
then call <a class="link" href="gio-GAsyncInitable.html#g-async-initable-new-finish" title="g_async_initable_new_finish ()"><code class="function">g_async_initable_new_finish()</code></a> to get the new object and check
for any errors.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>object_type</code></em> :</span></p></td>
<td>a <a href="../gobject/gobject-Type-Information.html#GType"><span class="type">GType</span></a> supporting <a class="link" href="gio-GAsyncInitable.html#GAsyncInitable" title="GAsyncInitable"><span class="type">GAsyncInitable</span></a>.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>io_priority</code></em> :</span></p></td>
<td>the <a class="link" href="gio-GIOScheduler.html#io-priority">I/O priority</a>
of the operation.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>cancellable</code></em> :</span></p></td>
<td>optional <a class="link" href="gio-GCancellable.html#GCancellable" title="GCancellable"><span class="type">GCancellable</span></a> object, <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>callback</code></em> :</span></p></td>
<td>a <a class="link" href="gio-GAsyncResult.html#GAsyncReadyCallback" title="GAsyncReadyCallback ()"><span class="type">GAsyncReadyCallback</span></a> to call when the initialization is
finished</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
<td>the data to pass to callback function</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>first_property_name</code></em> :</span></p></td>
<td>the name of the first property, or <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> if no
properties</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>...</code></em> :</span></p></td>
<td>the value of the first property, followed by other property
value pairs, and ended by <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.22</p>
</div>
<hr>
<div class="refsect2">
<a name="g-async-initable-new-finish"></a><h3>g_async_initable_new_finish ()</h3>
<pre class="programlisting"><a href="../gobject/gobject-The-Base-Object-Type.html#GObject"><span class="returnvalue">GObject</span></a> *           g_async_initable_new_finish         (<em class="parameter"><code><a class="link" href="gio-GAsyncInitable.html#GAsyncInitable" title="GAsyncInitable"><span class="type">GAsyncInitable</span></a> *initable</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gio-GAsyncResult.html#GAsyncResult" title="GAsyncResult"><span class="type">GAsyncResult</span></a> *res</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> **error</code></em>);</pre>
<p>
Finishes the async construction for the various g_async_initable_new calls,
returning the created object or <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on error.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>initable</code></em> :</span></p></td>
<td>the <a class="link" href="gio-GAsyncInitable.html#GAsyncInitable" title="GAsyncInitable"><span class="type">GAsyncInitable</span></a> from the callback</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>res</code></em> :</span></p></td>
<td>the <span class="type">GAsyncResult.from</span> the callback</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>error</code></em> :</span></p></td>
<td>a <a href="../glib/glib-Error-Reporting.html#GError"><span class="type">GError</span></a> location to store the error occuring, or <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to
ignore.</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>a newly created <a href="../gobject/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a>, or <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> on error. Free with
<a href="../gobject/gobject-The-Base-Object-Type.html#g-object-unref"><code class="function">g_object_unref()</code></a>. <span class="annotation">[<acronym title="Free data after the code is done."><span class="acronym">transfer full</span></acronym>]</span>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.22</p>
</div>
<hr>
<div class="refsect2">
<a name="g-async-initable-new-valist-async"></a><h3>g_async_initable_new_valist_async ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_async_initable_new_valist_async   (<em class="parameter"><code><a href="../gobject/gobject-Type-Information.html#GType"><span class="type">GType</span></a> object_type</code></em>,
                                                         <em class="parameter"><code>const <a href="../glib/glib-Basic-Types.html#gchar"><span class="type">gchar</span></a> *first_property_name</code></em>,
                                                         <em class="parameter"><code><span class="type">va_list</span> var_args</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> io_priority</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gio-GCancellable.html#GCancellable" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gio-GAsyncResult.html#GAsyncReadyCallback" title="GAsyncReadyCallback ()"><span class="type">GAsyncReadyCallback</span></a> callback</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
<p>
Helper function for constructing <span class="type">GAsyncInitiable</span> object. This is
similar to <a href="../gobject/gobject-The-Base-Object-Type.html#g-object-new-valist"><code class="function">g_object_new_valist()</code></a> but also initializes the object
asynchronously.
</p>
<p>
When the initialization is finished, <em class="parameter"><code>callback</code></em> will be called. You can
then call <a class="link" href="gio-GAsyncInitable.html#g-async-initable-new-finish" title="g_async_initable_new_finish ()"><code class="function">g_async_initable_new_finish()</code></a> to get the new object and check
for any errors.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>object_type</code></em> :</span></p></td>
<td>a <a href="../gobject/gobject-Type-Information.html#GType"><span class="type">GType</span></a> supporting <a class="link" href="gio-GAsyncInitable.html#GAsyncInitable" title="GAsyncInitable"><span class="type">GAsyncInitable</span></a>.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>first_property_name</code></em> :</span></p></td>
<td>the name of the first property, followed by
the value, and other property value pairs, and ended by <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>var_args</code></em> :</span></p></td>
<td>The var args list generated from <em class="parameter"><code>first_property_name</code></em>.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>io_priority</code></em> :</span></p></td>
<td>the <a class="link" href="gio-GIOScheduler.html#io-priority">I/O priority</a>
of the operation.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>cancellable</code></em> :</span></p></td>
<td>optional <a class="link" href="gio-GCancellable.html#GCancellable" title="GCancellable"><span class="type">GCancellable</span></a> object, <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>callback</code></em> :</span></p></td>
<td>a <a class="link" href="gio-GAsyncResult.html#GAsyncReadyCallback" title="GAsyncReadyCallback ()"><span class="type">GAsyncReadyCallback</span></a> to call when the initialization is
finished</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
<td>the data to pass to callback function</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.22</p>
</div>
<hr>
<div class="refsect2">
<a name="g-async-initable-newv-async"></a><h3>g_async_initable_newv_async ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                g_async_initable_newv_async         (<em class="parameter"><code><a href="../gobject/gobject-Type-Information.html#GType"><span class="type">GType</span></a> object_type</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#guint"><span class="type">guint</span></a> n_parameters</code></em>,
                                                         <em class="parameter"><code><a href="../gobject/gobject-The-Base-Object-Type.html#GParameter"><span class="type">GParameter</span></a> *parameters</code></em>,
                                                         <em class="parameter"><code><span class="type">int</span> io_priority</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gio-GCancellable.html#GCancellable" title="GCancellable"><span class="type">GCancellable</span></a> *cancellable</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gio-GAsyncResult.html#GAsyncReadyCallback" title="GAsyncReadyCallback ()"><span class="type">GAsyncReadyCallback</span></a> callback</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> user_data</code></em>);</pre>
<p>
Helper function for constructing <span class="type">GAsyncInitiable</span> object. This is
similar to <a href="../gobject/gobject-The-Base-Object-Type.html#g-object-newv"><code class="function">g_object_newv()</code></a> but also initializes the object asynchronously.
</p>
<p>
When the initialization is finished, <em class="parameter"><code>callback</code></em> will be called. You can
then call <a class="link" href="gio-GAsyncInitable.html#g-async-initable-new-finish" title="g_async_initable_new_finish ()"><code class="function">g_async_initable_new_finish()</code></a> to get the new object and check
for any errors.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>object_type</code></em> :</span></p></td>
<td>a <a href="../gobject/gobject-Type-Information.html#GType"><span class="type">GType</span></a> supporting <a class="link" href="gio-GAsyncInitable.html#GAsyncInitable" title="GAsyncInitable"><span class="type">GAsyncInitable</span></a>.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>n_parameters</code></em> :</span></p></td>
<td>the number of parameters in <em class="parameter"><code>parameters</code></em>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>parameters</code></em> :</span></p></td>
<td>the parameters to use to construct the object</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>io_priority</code></em> :</span></p></td>
<td>the <a class="link" href="gio-GIOScheduler.html#io-priority">I/O priority</a>
of the operation.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>cancellable</code></em> :</span></p></td>
<td>optional <a class="link" href="gio-GCancellable.html#GCancellable" title="GCancellable"><span class="type">GCancellable</span></a> object, <a href="../glib/glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore.</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>callback</code></em> :</span></p></td>
<td>a <a class="link" href="gio-GAsyncResult.html#GAsyncReadyCallback" title="GAsyncReadyCallback ()"><span class="type">GAsyncReadyCallback</span></a> to call when the initialization is
finished</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>user_data</code></em> :</span></p></td>
<td>the data to pass to callback function</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 2.22</p>
</div>
</div>
<div class="refsect1">
<a name="gio-GAsyncInitable.see-also"></a><h2>See Also</h2>
<a class="link" href="gio-GInitable.html#GInitable" title="GInitable"><span class="type">GInitable</span></a>
</div>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.17</div>
</body>
</html>